<template>
	<view>
		<!-- 页首 -->
		<zw-header></zw-header>
		<view class="top">
			<image class="banner" src="../../static/image/user/bg.png"></image>
			<image src="../../static/image/user/edit.png"
				style="width: 40px;position: absolute;right: 2%;top: 10%;height: 40px;" mode="widthFix"
				@click="goUrl('/pages/user/profile/index')"></image>
		</view>
		<!-- 左侧导航栏 -->
		<menu-wrapper active-index="2-1" style="background-color: #fff;padding: 0;width: 80%;margin: 0 auto;">
			<view class="card-header">
				<view class="left">
					<fui-avatar background="#fff" width="180" :src="loginUser.avator"
						style="position: absolute;top: 48%;"></fui-avatar>
					<view class="user-info">
						<view class="user-name elip">{{loginUser.name}}</view>
						<view class="tip">{{loginUser.info}}</view>
					</view>
				</view>
				<view class="right" style="display: flex;justify-content: flex-start;align-items: center;">
					<view class="item" style="margin-left: 0rpx;">
						<view class="value">
							{{loginUser.fucusNum}}
						</view>
						<view class="name">关注</view>
					</view>
					<view class="item">
						<view class="value">{{loginUser.fansNum}}</view>
						<view class="name">粉丝</view>
					</view>
					<view class="item">
						<view class="value">{{loginUser.fansNum}}</view>
						<view class="name">获赞</view>
					</view>
					<view class="item">
						<view class="value">{{loginUser.productNum}}</view>
						<view class="name">发布</view>

					</view>
					<view class="item">
						<view class="value">{{loginUser.fansNum}}</view>
						<view class="name">被同款</view>

					</view>
				</view>
			</view>
			<view style="display: flex;justify-content: flex-start;align-items: center;margin-top: 25px;">
				<view :class="tabIndex==1?'active':'lable'" @click="clickOption(1)">AI生成</view>
				<view style="margin-left: 15px;" :class="tabIndex==2?'active':'lable'" @click="clickOption(2)">帖子</view>
				<view style="margin-left: 15px;" :class="tabIndex==3?'active':'lable'" @click="clickOption(3)">合集</view>
			</view>
			<view class="card-body">
				<view class="container"
					style="display: flex;justify-content: flex-start;align-items: center;border-top: 1px solid #C4BFBF;margin-top: 20px;">
					<fui-empty isFixed width="200" height="200" marginTop="400" src="../../static/image/user/empty.png"
						title="暂无数据"></fui-empty>
				</view>
			</view>
		</menu-wrapper>

		<!-- 页脚 -->
		<tool-bar :scrollTop="scrollTop"></tool-bar>
	</view>
</template>

<script>
	import menuWrapper from '@/components/user/common/menu-wrapper.vue';
	import centerConfig from '@/common/config/user/center.config.js';

	import {
		mapState
	} from 'vuex';

	export default {
		components: {
			menuWrapper
		},
		data() {
			return {
				...centerConfig,
				accountInfo: {},
				counts: [],
				tabIndex: 1,
			}
		},
		computed: {
			...mapState(['loginUser']),
			currentTime() {
				const currentHour = new Date().getHours();
				const timeQuantums = ['凌晨', '上午', '下午', '晚上'];
				return timeQuantums[Math.floor(currentHour / 6)];
			}
		},
		onLoad() {
			this.getAccountInfo();
			this.findCounts();
			this.$store.commit('tab', 0);
		},
		methods: {
			goUrl(url) {
				uni.navigateTo({
					url: url,
					fail(err) {
						console.log(err)
					}
				})
			},
			clickOption(index) {
				this.tabIndex = index;
				// this.page = 0;
				// this.promos = [];
				// this.findPicture();
			},
			getAccountInfo() {
				this.$util.request('/security/getAccountInfo', {}, (res) => {
					this.accountInfo = res.accountInfo;
				}, true);
			},
			findCounts() {
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				this.$util.request('/profile/counts', {}, (res) => {
					uni.hideLoading();
					this.counts = res;
				}, true);
			}
		}
	}
</script>

<style lang="scss">
	.top {

		position: relative;
		width: $page-width;
		margin: 0 auto;
	}

	.lable {
		font-family: 思源黑体;
		font-size: 16px;
		font-weight: bold;
		line-height: normal;
		text-align: center;
		display: flex;
		align-items: center;
		letter-spacing: 0em;

		color: #666666;
	}

	.active {
		font-family: 思源黑体;
		font-size: 16px;
		font-weight: bold;
		line-height: normal;
		display: flex;
		align-items: center;
		letter-spacing: 0em;
		border-bottom: 2px solid #080808;
		color: #000000;
	}

	.banner {
		width: 100%;
		height: 200px;
		margin: 0 auto;
		display: flex;
		justify-content: center;
	}

	.avatar {
		width: 100px;
		height: 100px;
		padding: 4px;
		border: 3px solid #FFFFFF;
		border-radius: 100px;
		object-fit: fill;
	}

	.card-header {
		// padding-top: 24px;
		justify-content: space-between;
		@extend %flex-align-center;

		.left {
			@extend %flex-align-center;



			.user-info {
				width: 302px;
				margin-left: 31%;
				// margin-top: -25px;

				.user-name {
					max-width: 220px;
					font-family: Source Han Sans;
					font-size: 24px;
					font-weight: bold;
					font-feature-settings: "kern" on;
					color: #3D3D3D;
				}

				.tip {
					margin-top: 5px;
					font-family: 思源黑体;
					font-size: 12px;
					font-weight: normal;
					line-height: 18px;
					letter-spacing: 0px;
					color: #3D3D3D;
				}

				.link {
					display: inline-block;
					font-size: 12px;
					margin-top: 10px;
					color: $color-primary;
				}
			}
		}

		.right {

			.item {
				@extend %flex-align-center;
				padding: 6px 0;
				margin-left: 66rpx;
				color: #757575;
				display: block;
				text-align: center;

				.value {
					font-family: HarmonyOS Sans SC;
					font-size: 18px;
					font-weight: bold;
					line-height: 35px;
					text-align: center;
					letter-spacing: 0px;
					color: #000000;
				}

				.name {
					font-family: 思源黑体;
					font-size: 12px;
					font-weight: normal;
					line-height: 20px;
					text-align: center;
					letter-spacing: 0px;
					color: #666666;
				}
			}

		}
	}

	.card-body {
		display: flex;
		flex-wrap: wrap;
		margin-top: 5px;
		padding-top: 50px;
		border-top: 1px solid $border-color;

		.button {
			margin-bottom: 60px;
			@extend %flex-align-center;

			.btn-icon {
				width: 100px;
				height: 100px;
				border-radius: 50%;
			}

			.right {
				width: 276px;
				margin-left: 20px;

				.top {
					@extend %flex-align-center;
					font-size: 18px;
					font-weight: 400;

					.name {
						color: #757575;
					}

					.value {
						color: $color-primary;
					}
				}

				.link {
					line-height: 1.8;
					@extend %flex-align-center;
					color: #757575;
					cursor: pointer;

					&:hover {
						color: $color-primary;
					}

					.icon {
						font-weight: bold;
					}
				}
			}
		}
	}
</style>